﻿using System;

using System.Collections.Generic;
using System.Text;
using Silvermoon.OpenGL.Native;

namespace Silvermoon.OpenGL
{
    public static class Capabilities
    {
        #region Properties

        public static bool AlphaTest
        {
            get { return GetEnabled(Capability.AlphaTest); }
            set { Change(Capability.AlphaTest, value); }
        }

        public static bool Blend
        {
            get { return GetEnabled(Capability.Blend); }
            set { Change(Capability.Blend, value); }
        }


        public static bool ClipPlane0
        {
            get { return GetEnabled(Capability.ClipPlane0); }
            set { Change(Capability.ClipPlane0, value); }

        }

        public static bool ColorLogicOp
        {
            get { return GetEnabled(Capability.ColorLogicOp); }
            set { Change(Capability.ColorLogicOp, value); }
        }

        public static bool ColorMaterial
        {
            get { return GetEnabled(Capability.ColorMaterial); }
            set { Change(Capability.ColorMaterial, value); }
        }

        public static bool CullFace
        {
            get { return GetEnabled(Capability.CullFace); }
            set { Change(Capability.CullFace, value); }
        }

        public static bool DepthTest
        {
            get { return GetEnabled(Capability.DepthTest); }
            set { Change(Capability.DepthTest, value); }

        }

        public static bool Dither
        {
            get { return GetEnabled(Capability.Dither); }
            set { Change(Capability.Dither, value); }

        }

        public static bool Fog
        {
            get { return GetEnabled(Capability.Fog); }
            set { Change(Capability.Fog, value); }

        }

        public static bool IndexLogicOpMode
        {
            get { return GetEnabled(Capability.IndexLogicOpMode); }
            set { Change(Capability.IndexLogicOpMode, value); }

        }

        public static bool Light0
        {
            get { return GetEnabled(Capability.Light0); }
            set { Change(Capability.Light0, value); }

        }

        public static bool Light1
        {
            get { return GetEnabled(Capability.Light1); }
            set { Change(Capability.Light1, value); }

        }

        public static bool Lightening
        {
            get { return GetEnabled(Capability.ColorLogicOp); }
            set { Change(Capability.ColorLogicOp, value); }

        }

        public static bool LineSmooth
        {
            get { return GetEnabled(Capability.LineSmooth); }
            set { Change(Capability.LineSmooth, value); }

        }

        public static bool LogicOpMode
        {
            get { return GetEnabled(Capability.LogicOpMode); }
            set { Change(Capability.LogicOpMode, value); }

        }

        public static bool PointSmooth
        {
            get { return GetEnabled(Capability.PointSmooth); }
            set { Change(Capability.PointSmooth, value); }

        }

        public static bool Normalize
        {
            get { return GetEnabled(Capability.Normalize); }
            set { Change(Capability.Normalize, value); }

        }

        public static bool ScissorBox
        {
            get { return GetEnabled(Capability.ScissorBox); }
            set { Change(Capability.ScissorBox, value); }

        }

        public static bool ScissorTest
        {
            get { return GetEnabled(Capability.ScissorTest); }
            set { Change(Capability.ScissorTest, value); }

        }

        public static bool StencilTest
        {
            get { return GetEnabled(Capability.StencilTest); }
            set { Change(Capability.StencilTest, value); }

        }

        public static bool Texture2D
        {
            get { return GetEnabled(Capability.Texture2D); }
            set { Change(Capability.Texture2D, value); }

        }

        #endregion
        #region private methods

        private static bool GetEnabled(Capability capability)
        {
            return gl.IsEnabled(capability) != 0;
        }

        private static void Change(Capability capability, bool value)
        {
            if (value) gl.Enable(capability); else gl.Disable(capability);
        }
        #endregion
    }
}
